<?php
namespace app\index\controller;

use app\index\model\Staff;
use think\Validate;

class Index
{
    public function index()
    {
//        return '1111Hello,world!';

        $rule = [
            'name'  => 'require|max:25',
            'age|年龄'   => 'number|between:1,120',
            'email' => 'email',

        ];

        $data = [
            'name'  => 'thinkphp',
            'age'   => 121,
            'email' => 'thinkphp@qq.com',
        ];

        $validate = new Validate($rule);
        $result   = $validate->check($data);
        if(!$result){
            echo $validate->getError();
        }
    }
    public function test()
    {
        $rule = [
            'name'  => 'require|max:25',
            'age'   => 'number|between:1,120',
            'email' => 'email',
        ];
        $msg = [
            'name.require' => '名称必须',
            'name.max'     => '名称最多不能超过25个字符',
            'age.number'   => '年龄必须是数字',
            'age.between'  => '年龄2222必须在1~120之间',
            'email'        => '邮箱格式错误',
        ];
        $data = [
            'name'  => 'thinkphp',
            'age'   => 121,
            'email' => 'thinkphp@qq.com',
        ];
        $validate = new Validate($rule,$msg);
        $result   = $validate->check($data);
        if(!$result){
            echo $validate->getError();
        }
    }


    public function staff(){
        $staffModel = new Staff();
        dump($staffModel);die;
    }

}
